package org.darcy.admin.task.brokerage;

import org.darcy.admin.task.order.OrderReceiptTask;
import org.darcy.common.utils.DateUtil;
import org.darcy.service.service.UserBrokerageRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 佣金冻结期解冻task
 */
@Component
@Configuration // 读取配置
@EnableScheduling // 2.开启定时任务
public class BrokerageFrozenTask {

	// 日志
	private static final Logger logger = LoggerFactory.getLogger(OrderReceiptTask.class);

	@Autowired
	private UserBrokerageRecordService userBrokerageRecordService;

	// @Scheduled(fixedDelay = 1000 * 60 * 60L) //1小时同步一次数据
	@Scheduled(fixedDelay = 1000 * 60L) // 1分钟同步一次数据
	public void init() {
		logger.info("佣金冻结期解冻: {}", DateUtil.nowDateTimeStr());
		try {
			userBrokerageRecordService.brokerageThaw();
		} catch (Exception e) {
			logger.error("BrokerageFrozenTask.task" + " | msg : " + e.getMessage());
		}

	}
}
